home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr47 / masm.zip / ASSEMBLR.MES < prev    next >
Text File  |  1993-04-07  |  25KB  |  69 lines

  1.  
  2.  
  3.  
  4.                         Bruce T. Holmes
  5.                         802 Madison
  6.                         Evanston, IL 60202
  7.                         312-869-3434
  8.  
  9. Notice: At the end of this article is information on a class in Assembler.
  10.  
  11. Entering the Guild of the Magicians: Tools for Learning Assembly Language Programming
  12.  
  13.     I used to think I was intelligent.  Then I tried learning assembly language programming on my PC and found my feelings of self-worth sorely tested.  But I kept telling myself there are few bad learners in the world, and I certainly was not one of them.  I unabashedly blamed my difficulties on poor instruction, and, in retrospect, I think I was right.  In the end I have come full circle, and am now feeling very good about what I've mastered.  But it was a rocky road, and if I had known then what I know now I would not have had to travel it.  Which is obviously a silly thing to say since it's true of everything we learn in life.
  14.     When I began my commitment to assembler there were only a few books available on the subject.  Despite what their advertising blurbs proclaimed, they were not teaching texts.  In the past year the situation has improved considerably and a number of books have come out which do an excellent job of taking the beginner by the hand and creating a learning experience. They came too late for me, but at least fellow travelers do not face the potholes I stumbled over.
  15.     IBM PC ASSEMBLY LANGUAGE, A GUIDE FOR PROGRAMMERS by Leo Scanlon is the book I began with.  It starts out well with a good introduction, and for the first two chapters I was lulled into a false sense of optimism.  Scanlon ends chapter two with a little program you can key in.  He then explains how to assemble the program.  After that the book abandons a teaching format and becomes a reference text discussing each instruction in turn.  Reading all this information without any means of using it, playing with it, or making it meaningful, was a mind-numbing experience.  I can't tell you how I ranted and raved against poor Mr. Scanlon.  This is not a book for beginners.
  16.     So why do I still use it so frequently?  The truth is, when dealing with the 8088 instruction set it is a wonderful reference source.  It has a separate section on each instruction and is by far the easiest to turn to of the all the assembler books I have in my library. It also has some very useful programs on such basic procedures as binary to ascii conversion and 32 bit multiplication and division. I've discovered one or two errors in these procedures, but generally they've been very useful and informative.  The book is sorely lacking in its descriptions of DOS and BIOS function calls, but in most other ways it's a good reference source.  Despite my history of aggravation with this book, I recommend it.  The further you progress in your understanding, the more you'll appreciate it.
  17.     However, that is in retrospect.  In the beginning I felt abandoned by Scanlon's reversion to a reference text and I went looking for help.  I had high hopes for 8088 ASSEMBLER LANGUAGE PROGRAMMING: THE IBM PC by Willen & Krantz.  It's an attractive-looking book with helpful diagrams, and I started in on the introductory material with great confidence.  I had already read the information concerning hexadecimal numbering and the offset addressing system in Scanlon's book, so it was my second time through the material, and I felt like an old, knowledgeable pro.  I do recommend using as many different sources as possible as you learn.  What you find difficult in one book may seem more accessible when explained by a second author in a slightly different way.
  18.     Eventually the Willen & Krantz book also lost me.  It is much more a description of how the IBM system works than a tutorial on assembly language.  I had no way to make use of the material, and eventually my brain became overloaded with aimless pieces of information, floating around like driftwood, without any way to anchor themselves.  The authors do include some sample programs with explanatory material, and if you are willing to work your way through them, you will pick up a little.  But the book does nothing uniquely well and I have not used it in months.  There are better books available and I would avoid this one.
  19.     There is something about THE 8086/8088 PRIMER by Stephen P. Morse which is thoroughly intimidating.  The typesetting, the layout and design of the book, the look of the illustrations, all made me feel as if I were about to tackle a technical manual. Well, the book is every bit as technical as it looks.  There is no explanation of such fundamental concepts as the hexadecimal numbering system, and I quickly realized that I was in over my head.  In all fairness the book does not present itself as a teacher of assembly language programming.  Stephen Morse is the man who designed the 8086 microprocessor, and he knows more about what's going on here than any rational being would want to know.  As with the book by Willen & Krantz, its primary focus is the 8086/8088 system.  But this time you are listening to the man who knows everything.  Have you always yearned to know how the bit distribution works in an increment instruction?  Do you even know what an increment instruction does?
  20.     So why have I even mentioned the book here?  Well, I was in for a pleasant surprise.  Tucked away in the back of the book are three chapters on programming.  One chapter discusses Pascal, another PL/M, and another introduces us to assembly.  I happened to glance at the chapter on assembly.  I short while later I realized I had made it through ten pages.  The material was making perfect sense to me.  You cannot imagine my surprise.  And this without having made it through the rest of the book.  I do doubt whether I would have managed as well if I had begun with the Morse book.  All my other readings contributed to my understanding, and I can never go back to my initial level of ignorance in order to fairly evaluate one book's clarity over another.  I certainly would not begin with this book, but, for the assembly chapter alone, I'm glad I have it.  If you have some experience under your belt this might prove a worthwhile read.
  21.     If the above books are so unsuited to teaching, what's the solution?  How should assembly language be taught?  The same way anything else should be taught.  Sequentially, allowing experience to develop and grow.  One should begin with small, simple programs which have minimal functions.  Gradually, as the student gains greater experience, additional commands can be introduced.  At all times there must be hands-on experience and the chance to absorb one detail before going onto the next.  If the student at any time reads a sentence with more than a dozen new and undefined words in it, you can count on the student's brain going into system lockup.  There is nothing so discouraging as not being able to understand the sentence before you.
  22.     They came to late for me, but there are books out now which teach.  The best of these is ASSEMBLY LANGUAGE PRIMER FOR THE IBM PC & XT by Robert Lafore.  For someone who's done some assembler programming on other systems, Robert's painstaking approach would be slow torture.  But for a beginner, this is the solution.  Robert is a teacher.  Slow, patient, conversational, letting you play with the computer.  Building carefully on what has come before.  Explaining everything.  I would have given a couple of pints of blood for this book when I was beginning.  Of special notice, Lafore's is just about the only book to cover the use of DOS 2 file handles so that one can use paths into subdirectories.  If you're just beginning, this is where to begin.
  23.     There are a few more books I can recommend, two of them quite similar.  Peter Abel did a very nice job on ASSEMBLER FOR THE IBM PC AND PC-XT.  He moves faster than Lafore, but for some people that may be an advantage.  Abel's book is a cross between a teaching text and a reference book.  Where Lafore follows the logic of learning, Abel is much more structured and better organized as he presents his subjects.  He is often able to go into more detail since he doesn't offer as much of the process of learning.  When I need a well-organized lecture concerning the different possibilities available when writing code for say, a printing subroutine, this is where I turn.
  24.     Assembly Language Programming for the IBM Personal Computer by David J. Bradley assumes programming experience on the part of the reader and provides more technical background than Abel's effort.  Bradley was part of the team that designed the IBM PC and he offers insights concerning the ROM BIOS routines that you will find nowhere else.  But it is definitely not a teaching book for beginners.  Additionally, there is no use of boxes or design elements in the layout of the text to direct the reader's eye toward salient points.  So I rarely use it for quick answers to my problems.  But it is an excellent way to broaden your understanding and abilities when you have an hour or two for some serious reading.
  25.     The Serious Assembler by Charles A. Crayne and Dian Girard isn't quite as serious as it sounds.  It's a good book with a better than average coverage of the use of system interupts.  But it is not a wealth of previously uncovered gems that the "beginner" books failed to cover.  One point worth considering about The Serious Assembler is its price, $8.95.  This is half the cost of the other books.  When picking out a backup instructional text, this would go high on my list.
  26.     There is one last required text if you are interested in assembler under PC or MS DOS.  While half of assembler programming is knowing how to use the 8088 instructions, the other half is knowing how to use the system calls.  Most of the texts mentioned above are surprisingly bad at providing this sort of information.  I've found four sources that do.  Both IBM and Microsoft sell Disk Operating Sytems Programmers Reference Manuals.  IBM's version goes for $100; Microsoft sells its for $40.  Not cheap.  What I've used for many months is the MS-DOS PROGRAMMER'S REFERENCE MANUAL put out by Radio Shack which costs a more reasonable $20.  I wish I could give some people credit for this, because they did a nice job.  This is a wonderful, well-organized reference source that I could not work without.
  27.     However, I can recall wasting time on a couple of occasions because of misleading information.  You will find a couple of BIOS calls which were implemented on the Radio Shack machine and which are not available on the IBM.  Don't expect the BIOS routine for scrolling left or right to have any noticeable effect.  Perhaps spending an extra $20 for the Microsoft version would have been worth the expense.  There is an issue here which applies to your choice of assemblers as well.  Getting the ultimate reference may cost you through the nose.  But someday the extra expense may save you some time and aggravation.  I always have trouble paying the extra expense because I feel like I'm being taken advantage of.  I think, on occasion, I've paid a price.
  28.     On one occasion, after I had again lost a day of programming while trying to program a memory allocation routine without adequate explanation from the manual, I found a solution after consulting PROGRAMMER'S GUIDE TO MS-DOS by Dennis N. Jump.  He covers the same material as the reference manuals in a more conversational fashion with his own experience thrown in for guidance.  The only drawback is an unfortunate tendency to frame his examples as subroutines called from Pascal.
  29.     Another book which attempts to make the information in the manuals more easily accesible is the Bluebook of Assembly Routines for the IBM PC & XT by Christopher L. Morgan.  While providing a wide variety of essential sub-routines in a ready to use format seems like a tremendous idea, I find myself disappointed by the book.  Many of the subroutines are just examples of how to do BIOS or DOS function calls.  The DOS reference manuals are equally clear.  You will need routines such as conversion from binary to ascii, but you can find those elsewhere.  Scanlon's book has a number of such essentials.  For me the book's major drawback is a lack of explanation.  The routine is there, but there's no background, no attempt to explain or enlighten.  Sometimes this will limit the usefullness of the routine.  If you don't understand the larger context it's difficult to apply the example.  What we need as programmers is understanding.  You'll never turn into a cook if you only prepare TV dinners.
  30.     Instead of recommending one book with which to learn assembler on the IBM PC, I'm going to suggest a library.  You will need more than one resource, and often you will need to read two different explanations in order to understand a difficult concept.  For reference I would buy both the Scanlon book and one of the DOS reference manuals.  If you are a rank beginner you will need additional help.  Lafore, Abel, and Bradley are all good.  The Serious Assembler is both good and chaep.  It wouldn't hurt to have two of the three on hand for those sticky moments when you need an alternative view.
  31.     Recently I've noticed the release of additional books on assembly language programming.  I haven't seen everything that's available, so you would be foolish to discount a text simply because I haven't mentioned it.  As you make your selection at the bookstore, take the time to do some reading.  Does the author provide examples?  How much previous experience is assumed?  Do you understand the explanations?  Don't just assume that a good-looking book will do the job.  Read until you're ready to quit, and then keep reading.  Am I getting through on this one?  Bring a lawn chair and lunch.  Be prepared to camp out there for the day if need be.  You will pay dearly for a hasty decision.  Read extensively from the choices available and you will save yourself volumes of aggravation later.
  32.     There are two more requirements for working with assembler, an assembler and a debugger.  The Microsoft versions of these has in the past left something to be desired.  For years the only assembler that programmers had available was the Microsoft MASM v2.0.  We all bitched about the product and circulated a list of all the things you couldn't count on it to handle properly.  But beyond the bugs, what tested the limits of our patience, was the program's speed.  It was slow, incredibly slow.  Until recently there was no alternative.  Then Speedware came out with what they call the Turbo Assembler.  It is a combination editor and assembler.  And it is fast.  To those, like myself, used to the Microsoft assembler, the speed of the Turbo assembler was absolutely shocking.  It comes with its own editor, and if you're willing to adapt to a new editor, the easy interaction between the editing of mistakes and the compiling process might make a huge difference in your programming enjoyment.  I wasn't willing to make the transition, and while in theory you can adapt the editing commands to your own wishes, in reality it ain't that easily done.  So do I recommend the Turbo Assembler?
  33.     Fate has a funny way of turning the tables on us all.  The Turbo Assembler is a brand new program complete with it's own set of bugs.  A couple of times I've had some very erratic program behavior as a result of improper assembling.  Occasionally the turbo assembler reported a host of phase errors on a file which would assemble perfectly on Microsofts assembler.  It is not 100% compatible with the Microsoft assembler, and syntax errors are possible on files which according to the God Microsoft are correct.  There are additional limits.  The Speedware documentation is amateurish, the index minuscule.  I never bothered to use the notebook.  The program cannot assemble any file greater than 64K in length, or with too many labels.  At least my old Microsoft v2.0 never stopped me cold.  As much as I loved the Turbo Assembler's speed, I was never really able to rely on it.
  34.     Speedware offers a $49 version which produces com files directly.  This means you can't do a more complex job with separate obj files being linked together.  But when you're just starting out that may not seem a handicap.  If you decide assembler is for you, Speedware allows you to upgrade to its full function assembler which sells for $99.  Perhaps for a beginner this will seem an inexpensive way to ease into assembler.  Eventually the bugs will probably get fixed so this might seem a better approach than spending $150 on the Microsoft product.
  35.     And yet, I can recall a couple of days I lost tracking down bugs which weren't there.  I remember those as frustrating days.  Your time is worth something.
  36.     So, as much as I would like to be able to champion the little guy taking on the Microsoft Goliath, I can't yet recommend the product.
  37.     I mentioned fate a second ago.  At about the same time the Turbo Assembler was making it's appearance Microsoft released version 3.0 of it's assembler.  It was still slow, but they had dealt with the bugs.
  38.     Due to the huge difference in speed I continued to use the Speedware assembler for quite a few months.  But I paid for the time saved with a day or two lost tracking down those bugs which turned out to have been incorrect assembling.  Then came the coup de grace.  Microsoft came out with version 4.0.
  39.     Microsoft claims this one is faster than the competition, bar none.  They may be right.  They've also come out with new documentation.  In a comparison of the Microsoft and IBM MASMs, PC Magazine once gave the nod to IBM on the basis of the superior manual.  The Microsoft manual is no longer a deficiency.  In fact, it's fairly good.  Version 4.0 is a new product and I managed to get one undocumented error message and one totally eroneous error message on my very first day with it.  I've spent some money calling Microsoft for support and the last time I called the poor girl had no idea how to resolve the problem.  She said she'd talk to a technical higher up and have someone get back to me.  That was about a month ago.
  40.     Perhaps perfection is just not to be expected in this life.  There are other selling points to the Microsoft version that you won't find elsewhere.  Included in the package you will find a library manager, a program called Make which allows for automatic assembling of source files which haven't been assembled since your last changes,  and a useable symbolic debugger, Symdeb.  That last item is the knockout punch.  For someone just getting started, not having to purchase a separate debugger could be a huge help.  And the truth is you can purchase Microsoft's Masm mail order for considerably less than $150.
  41.     I suppose I really ought to mention that IBM has version of MASM which they sell for $175.  Except their MASM is just the old slow Microsoft Masm v3.0 without the goodies, and it costs more.  Naw, maybe I won't mention it after all.  The Turbo Assembler is cheap but unreliable.  So the Microsoft package appears to be the way to go.  This is true even for someone just beginning and not wanting to spend too much money, because that debugger they're throwing in is important.
  42.     You see, the last piece of reality I might mention is that the programs you write in assembler won't necessarily work perfectly the first time out.  There is no high level language acting as a safety net and minor slipups on your part can have amazing results.  You will need a debugger.
  43.     The one good point about the Debug provided with MS DOS is that it's free.  In every other way you will pay dearly for it.  Don't even consider trying to use it.  There are any number of debuggers on the market.  Any of them would be an improvement and would save you significant amounts of time.  I'm going to discuss the one I'm using because I think it is worth recommending, but there may be others which would suit your needs just as well.  The Microsoft Symdeb debugger is free if you buy their Masm, and it handles the basics quite nicely.
  44.     But if you want to move up a bit, consider getting a periscope. I use and love a debugger called Periscope from Data Base Decisions.  There are two versions of the program.  One at $295 comes with a companion board, cutely titled Submarine, which provides protected memory so a run away program can't wipe out the debugger.  The second, purely software version, goes for $145.  Both versions have a breakout switch so you can interrupt your program at any time.  Even when your keyboard is locked up.
  45.     Periscope offer a host of capabilities, some normally only found on much more expensive products.  You can jump over procedures.  You can use the same symbols you used as you wrote the program to debug it.  I can't tell you what a difference that will make.  You can window whatever information you want on the screen.  If you have two monitors, you can use both screens; one for your program, one for the debugger.  You can jump over procedures.  You can cue the debugger to halt program execution based on a wide variety of conditions: reaching specific procedures, reading or writing data values, a critical value occurring in one of the registers, etc.  You can display your data field in a wide variety of formats.  You can break out of the program even during the most bizarre foul ups.  You can even trace backwards to discover what went wrong.
  46.     I could go on.  Actually, the best thing about the program is the least obvious.  This is the brainchild of one individual, Brett Salter.  If you call up Data Base Decisions for help, guess who gets on the line and talks you through it.  Updates arrive free and unsolicited.  I've talked to Brett on the phone and offered a few suggestions from my wish list and the next thing I knew Bret had sent me a new version with all my wishes fulfilled.  The program is constantly being improved and made more flexible.  In the dismal world of indifferent software manufacturers, Brett Salter is a miracle.
  47.     So, was learning assembler worth all the bother.  I think so.  If you're serious about programming, assembler gives you a wonderfully detailed view of how it all works.  Once you've mastered assembler and built up a library of procedures, the coding doesn't take that much longer than with a high level language. The code will not be terribly portable, but the 8088 instruction set and MS-DOS look like they have a healthy future.  Even if you choose a more portable language like C for most of your work, your experience with assembler will enhance your understanding of what's possible.
  48.     Being an assembler programmer leaves one with a special feeling, something like a novice who has finally entered the guild of the magicians.  I wish you luck.
  49.                         Bruce T. Holmes
  50.                         September 2, 1986
  51.  
  52. IBM PC ASSEMBLY LANGUAGE, A GUIDE FOR PROGRAMMERS by Leo J. Scanlon, Robert J. Brady Co., $19.95
  53. 8088 ASSEMBLER LANGUAGE PROGRAMMING: THE IBM PC by David C. Willen & Jeffrey I. Krantz, Howard W. Sams & Co., $15.95
  54. THE 8086/8088 PRIMER by Stephen P. Morse, Hayden Book Co., $11.95 
  55. ASSEMBLY LANGUAGE PRIMER FOR THE IBM PC & XT by Robert Lafore, The Waite Group, NAL $21.75
  56. ASSEMBLER FOR THE IBM PC AND PC-XT by Peter Abel, Reston Publishing
  57. ASSEMBLY LANGUAGE PROGRAMMING FOR THE IBM PERSONAL COMPUTER by David Bradley, Prentice Hall, $24.95
  58. THE SERIOUS ASSEMBLER by Charles A. Crayne and Dian Girard, Baen Books, $8.95
  59. MS-DOS PROGRAMMER'S REFERENCE MANUAL, Radio Shack, Cat. No. 26-5403, $19.95
  60. IBM DISK OPERATING SYSTEM TECHNICAL REFERENCE, IBM Entry Systems, Old Orchard Road, Armonk, NY 10504,  (914) 765-1900,  $100.00
  61. TURBO ASSEMBLER by Uriah Barnett, Speedware, 2931 Northrop Avenue, Sacramento, CA 95825,  (916) 988-7426,  $49/$99
  62. MACRO ASSEMBLER v3.0 Microsoft Corporation, 10700 Northup Way, Bellevue, WA 98009,  (206) 828-8080,  $150.00
  63. MACRO ASSEMBLER v2.0 IBM 
  64. PERISCOPE by Brett Salter, Data Base Decisions, 14 Bonnie Lane, Atlanta, GA 30328,  (404) 256-3860,  $145/$295
  65.  
  66. ASSEMBLER CLASS
  67.     I took my assembler class three years ago from a woman who knew assembler quite well but was not a great teacher.  After working continuously with the language for the last 3 years, I often find myself thinking about how that course should have been run.  The thing I do best in life is teach and it might be fun to teach a course in assembler.
  68.     The goal would be to leave the class members with the tools, experience, and understanding necessary to continue on their own.  Once you've created your support procedures, assembler can be just as fast as any other language.  Part of the goal of the class could be to communally create those procedures.  I would also want to emphasize intelligent programming practices.  All the things I wish someone had told me all those many years ago.  The class would run maybe 10 or 12 weeks, one night a week.  Smoking would not be allowed in the class.  The class would cost at least $100, class size would affect this figure--the more people signed up, the less I would feel I had to charge to make it worth my while.
  69.     If you're interested drop me a note at 802 Madison, Evanston, IL  60202 with your name and address.  If enough people write expressing an interest, I would eventually get back to you with further details.  If there is not enough interest, you just wouldn't hear from me.  If you really want this to happen, you'll need to spread the word.        Bruce Holmes